import { render, createVNode, isVNode,nextTick} from 'vue'
import tsDialog from '@/components/scDialog/index1.vue'
export default {
    open(options) {
        let modal = createVNode(tsDialog, {
            ...options
        },
        // {
        //     // default: () => options.content,
        //     // footer:()=>options.content.slots.footer
        // }
        modalChildrenVNode(options.content)
       )
        modal.appContext = options.appContext 
        render(modal,options.box)
        modal.component.exposed.open()
    },
    destroy(box){
        render(null,box)
    }
}
const modalChildrenVNode =(content) =>{
    if (typeof content === "function") {
        return isVNode(content()) ? { default: () => content() } : undefined;
    }
    return isVNode(content) ? { default: () => content } : undefined;
}
/**
 *  return this.createVNode('parent-component', { slots }, (context) => {  
      const headerSlot = this.createVNode('child-component', null, { slots: { header: context.slots.header } });  
      const defaultSlot = this.createVNode('child-component', null, { slots: { default: context.slots.default } });  
      const footerSlot = this.createVNode('child-component', null, { slots: { footer: context.slots.footer } });  
      return [headerSlot, defaultSlot, footerSlot];  
    });  
 */